﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
using Forest.Core.Infrastructure;
using Forest.Cat.Admin.Models;
using Forest.Cat.Domain.Entities;
using Forest.Cat.Admin.Models.Applications;
using Forest.Cat.Admin.Models.JobHunting;

namespace Forest.Cat.Admin.Extensions
{
    public static class MappingExtensions
    {
        // LoginModel
        public static LoginModel ToModel(this Jobseeker entity)
        {
            if (entity == null)
                throw null;

            var model = new LoginModel()
            {
                FullName = entity.FullName,
            };
            return model;
        }

        public static ApplicationModel ApplicationToModel(this Application entity)
        {
            return new ApplicationModel
            {
                Id = entity.Id,
                CompanyId = entity.CompanyId,
                DateApplied = entity.DateApplied,
                Location = entity.WorkingLocation,
                JobId = entity.JobPositionId,
                PublishDays = DateTime.Now.Subtract(entity.StartDate).Days,
                ResumeId = entity.ResumeId,
                Status = entity.Status,
                StatusName = entity.Status == 1 ? "已申请" : "已读取"
            };
        }

        public static SavedJobModel SavedJobToModel(this SavedJob entity)
        {
            return new SavedJobModel
            {
                Id = entity.Id,
                CompanyId = entity.CompanyId,
                CompanyName = entity.CompanyName,
                JobTitle = entity.JobTitle,
                Location = entity.Location,
                PublishDays = DateTime.Now.Subtract(entity.StartDate).Days,
                DateSaved = entity.DateSaved,
                EndDate = entity.EndDate,
                JobPostingId = entity.JobPositionId,
                StartDate = entity.StartDate
            };
        }

        public static SavedCompanyModel SavedCompanyToModel(this SavedCompany entity)
        {
            return new SavedCompanyModel
            {
                Id = entity.Id,
                CompanyId = entity.CompanyId,
                CompanyName = entity.CompanyName,
                CompanyType = entity.CompanyType,
                DateSaved = entity.DateSaved,
                Employees = entity.Employees,
                Industry = entity.Industry,
                MissingNumber = 10
            };
        }

    }
}